package main

//go语言的接口都是隐式实现的
import (
	"fmt"
	"strings"
)

//接口类型，习惯上接口类型以er结尾
type talker interface {
	talk() string
}

type martian struct{}

//martian实现了t接口  不是显式的实现接口
func (m martian) talk() string {
	return "nack nack"
}

type laser int

//laser实现了t接口
func (l laser) talk() string {
	return strings.Repeat("pew ", int(l))
}

func shout(t talker) {
	louder := strings.ToUpper(t.talk())
	fmt.Println(louder)
}

type starship struct {
	laser
}

func main() {
	// shout(martian{})
	// shout(laser(2))
	s := starship{laser(3)}
	fmt.Println(s.talk())
	shout(s)
}
